home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / aspisrc.zip / TESTPAD.C < prev    next >
C/C++ Source or Header  |  1992-01-26  |  1KB  |  61 lines

  1. /* Find out if we need the pad field in the header for this machine
  2.    Copyright (C) 1991 Free Software Foundation
  3.  
  4.    This program is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU General Public License as
  6.    published by the Free Software Foundation; either version 1, or (at
  7.    your option) any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful, but
  10.    WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19. #include <stdio.h>
  20.  
  21. struct inc
  22. {
  23.   char a[20];
  24.   char b[20];
  25. };
  26.  
  27. struct test1
  28. {
  29.   char a;
  30.   struct inc in[5];
  31. };
  32.  
  33. struct test2
  34. {
  35.   char a;
  36.   char b;
  37.   struct inc in[5];
  38. };
  39.  
  40. main ()
  41. {
  42.   struct test1 t1;
  43.   struct test2 t2;
  44.   int t1diff, t2diff;
  45.   
  46.   t1diff = (char *)&t1.in - (char *)&t1;
  47.   t2diff = (char *)&t2.in - (char *)&t2;
  48.   
  49.   if (t2diff == t1diff + 1)
  50.     printf ("#define NEEDPAD\n");
  51.   else if (t1diff != t2diff)
  52.     fprintf (stderr, "Cannot determine padding for tar struct, \n\
  53. will try with none.\n");
  54.  
  55.   exit (0);
  56. }
  57.  
  58.       
  59.     
  60.   
  61.